package 线程和TCP网络编程.TAKS2.Socket;

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.Socket;

/**
 * 用户界面接收输出的端口
 *
 * @author 君未洋
 */
public class SocketOutputThread implements Runnable {

    public Socket socket;

    public SocketOutputThread(Socket socket) {
        this.socket = socket;
    }

    @Override
    public void run() {
        try {
            BufferedReader br = new BufferedReader(new InputStreamReader(socket.getInputStream()));
            while (true) {
                String str = br.readLine();
                //获取来自服务器的数据,如果有就打印出来
                //如果没有就陷入堵塞状态
                System.out.println(str);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }

    }

}